home *** CD-ROM | disk | FTP | other *** search
/ The Sunday Times: The Month 2004 August / The Sunday Times - The Month 2004-08.iso / pc / engine / modules / extras.swf / scripts / frame_1 / DoAction.as
Encoding:
Text File  |  2004-07-06  |  9.9 KB  |  358 lines

  1. function loadImage(mc, node, extrapath)
  2. {
  3.    var _loc3_ = extrapath;
  4.    if(_loc3_ == null)
  5.    {
  6.       _loc3_ = "";
  7.    }
  8.    var strDefaultPath = Tardis.ASSETS_FOLDER + "images/" + Tardis.ActiveSection.id + "/";
  9.    var _loc1_ = node.firstChild.nodeValue;
  10.    var _loc2_ = node.attributes.path;
  11.    if(_loc2_ != null)
  12.    {
  13.       _loc1_ = _loc2_ + _loc1_;
  14.    }
  15.    else
  16.    {
  17.       _loc1_ = strDefaultPath + _loc3_ + _loc1_;
  18.    }
  19.    if(strPathPrefix == null)
  20.    {
  21.       strPathPrefix = "";
  22.    }
  23.    mc.loadMovie(strPathPrefix + _loc1_);
  24. }
  25. function addLink(mc)
  26. {
  27.    Links[mc.link] = mc;
  28. }
  29. function getMCfromLink(Item)
  30. {
  31.    var _loc1_ = Item;
  32.    if(Links[_loc1_] == null)
  33.    {
  34.       var _loc2_ = [];
  35.       while(_loc1_ != sideMenu.ItemHome)
  36.       {
  37.          _loc2_.unshift(_loc1_._name.split("_").pop());
  38.          _loc1_ = _loc1_._parent._parent;
  39.       }
  40.       var _loc3_ = _loc2_.join("/");
  41.       Links[_loc1_] = Links[_loc3_];
  42.    }
  43.    return Links[_loc1_];
  44. }
  45. function removeLinkListener()
  46. {
  47.    Tardis.sideMenu.EB.removeListener(this);
  48. }
  49. function init()
  50. {
  51.    build();
  52. }
  53. function build()
  54. {
  55.    var strID = Tardis.ActiveSection.id;
  56.    var Colors = Tardis.Colors;
  57.    strSECTION_COLOR = Colors.getString(strID);
  58.    SECTION_COLOR = Colors.getHex(strID);
  59.    SECTION_COLOR50 = Colors.getHex(strID + "50");
  60.    DEFAULT_COLOR = Colors.getHex("default");
  61.    IMAGE_PATH = nodeData.attributes.imagepath;
  62.    var ndTitle = nodeData.byName("title");
  63.    if(ndTitle.getText() != null)
  64.    {
  65.       titleFF.htmlText = "<FONT COLOR=\"" + strSECTION_COLOR + "\">" + ndTitle.getText() + " </FONT>";
  66.       titleFF.resize();
  67.       titleFF._y = TEXT_POS - 7;
  68.       TEXT_POS += titleFF._height - 6;
  69.    }
  70.    ndExtras = nodeData.byName("items");
  71.    var arrClips = [];
  72.    var n = 0;
  73.    var ndExtra;
  74.    var n = 0;
  75.    while(n < ndExtras.childNodes.length)
  76.    {
  77.       ndExtra = ndExtras.childNodes[n];
  78.       this.attachMovie("extrasListingMC","mc_t_" + (n + 1),++depth);
  79.       objClip = eval("mc_t_" + (n + 1));
  80.       objClip._x = 8;
  81.       objClip.link = link = ndExtra.attributes.link;
  82.       objClip.navLink = true;
  83.       objClip.num = n;
  84.       objClip.imageRoll = false;
  85.       if(ndExtra.byName("print").getText() != null)
  86.       {
  87.          objClip.printImage = ndExtra.byName("print").getText();
  88.       }
  89.       if(ndExtra.byName("image").getText() != null)
  90.       {
  91.          objClip.imageRoll = true;
  92.       }
  93.       objClip.titleFF.htmlText = ndExtra.byName("title").getText();
  94.       objClip.titleFF.textColor = DEFAULT_COLOR;
  95.       objClip.titleFF.resize();
  96.       objClip.titleFF._y = CONTENT_POS;
  97.       objClip.btn._width = objClip.titleFF._width;
  98.       objClip.btn._height = objClip.titleFF._height;
  99.       objClip.bodyFF.htmlText = ndExtra.byName("body").getText();
  100.       objClip.bodyFF.textColor = DEFAULT_COLOR;
  101.       objClip.bodyFF.resize();
  102.       objClip.bodyFF._y = CONTENT_POS + objClip.titleFF._height - 9;
  103.       arrClips.push(objClip);
  104.       n++;
  105.    }
  106.    var ndBodyLink = nodeData.byName("bodylink");
  107.    if(ndBodyLink.byName("label").getText() != null)
  108.    {
  109.       animatedLink = false;
  110.       bodyLinkMC.printable = false;
  111.       bodyLinkMC.contentFF.htmlText = ndBodyLink.byName("label").getText();
  112.       bodyLinkMC.contentFF.textColor = SECTION_COLOR50;
  113.       var arwColor = new Color("bodyLinkMC.arrowMC.arwHolder");
  114.       bodyLinkMC.arrowMC.arwColor.setRGB(SECTION_COLOR50);
  115.       bodyLinkMC.link = ndBodyLink.attributes.link;
  116.       bodyLinkMC.navLink = true;
  117.       bodyLinkMC.contentFF.autoSize = true;
  118.       bodyLinkMC.btn._width = bodyLinkMC.contentFF._width + bodyLinkMC.arrowMC._x - 20;
  119.       bodyLinkMC.arrowMC._x = bodyLinkMC.contentFF._x + bodyLinkMC.contentFF._width + 1;
  120.       bodyLinkMC.mAnimatedLink._visible = false;
  121.    }
  122.    else if(ndBodyLink.byName("label_animated").getText() != null)
  123.    {
  124.       animatedLink = true;
  125.       bodyLinkMC.printable = false;
  126.       var arrLabels = ndBodyLink.byName("label_animated").getText().split("|");
  127.       bodyLinkMC.arrowMC._visible = false;
  128.       bodyLinkMC.mAnimatedLink.bigText = arrLabels[0];
  129.       bodyLinkMC.mAnimatedLink.smallText = arrLabels[1];
  130.       bodyLinkMC.mAnimatedLink.linkColor = SECTION_COLOR50;
  131.       bodyLinkMC.mAnimatedLink._visible = true;
  132.       bodyLinkMC.link = ndBodyLink.attributes.link;
  133.       bodyLinkMC.navLink = true;
  134.       bodyLinkMC.btn._width = bodyLinkMC.contentFF._width + bodyLinkMC.arrowMC._x - 20;
  135.    }
  136.    else
  137.    {
  138.       bodyLinkMC.arrowMC._visible = false;
  139.       bodyLinkMC._y = 385;
  140.       bodyLinkMC._height = 0;
  141.       bodyLinkMC._visible = false;
  142.       bodyLinkMC.btn.enabled = false;
  143.    }
  144.    ndItems = nodeData.byName("items");
  145.    ndDefault = nodeData.byName("items").firstChild;
  146.    var ndImage = ndDefault.byName("image");
  147.    if(ndImage.getText() != null)
  148.    {
  149.       loadFader();
  150.       intervalID = setInterval(checkLoad,300);
  151.    }
  152.    else
  153.    {
  154.       positionExtras();
  155.    }
  156.    onComplete();
  157. }
  158. function loadFader()
  159. {
  160.    var _loc1_ = this;
  161.    _loc1_.createEmptyMovieClip("mc_images",++depth);
  162.    mc_images.onReady = function()
  163.    {
  164.       var _loc1_ = this;
  165.       _loc1_.nodeData = _loc1_._parent.ndItems;
  166.       _loc1_.strPathPrefix = _loc1_._parent.strPathPrefix;
  167.       _loc1_.init();
  168.    };
  169.    mc_images.loadMovie(strPathPrefix + Tardis.ENGINE_FOLDER + "modules/preview_nofade.swf");
  170. }
  171. function checkLoad()
  172. {
  173.    if(mc_images._height > 0)
  174.    {
  175.       if(!positioned)
  176.       {
  177.          positioned = true;
  178.          positionExtras();
  179.          clearInterval(intervalID);
  180.       }
  181.    }
  182. }
  183. function positionExtras()
  184. {
  185.    mc_images._y = TEXT_POS;
  186.    TEXT_POS += mc_images._height;
  187.    n = 0;
  188.    while(n < ndExtras.childNodes.length)
  189.    {
  190.       objClip = eval("mc_t_" + (n + 1));
  191.       objClip._y = TEXT_POS;
  192.       TEXT_POS += 62;
  193.       n++;
  194.    }
  195.    mc_t_1.btn._height += mc_images._height;
  196.    mc_t_1.btn._y -= mc_images._height;
  197.    _visible = true;
  198. }
  199. function txtOver(mc)
  200. {
  201.    var _loc1_ = mc;
  202.    Tardis.sideMenu.doOver(_loc1_.link);
  203.    if(_loc1_.imageRoll)
  204.    {
  205.       mc_images.doOver(_loc1_.num);
  206.    }
  207.    if(_loc1_ == bodyLinkMC)
  208.    {
  209.       if(animatedLink)
  210.       {
  211.          bodyLinkMC.mAnimatedLink.mBuyOnlineText.txtLabel.textColor = SECTION_COLOR;
  212.          bodyLinkMC.mAnimatedLink.mBuyOnlineText2.contentFF.textColor = SECTION_COLOR;
  213.          bodyLinkMC.mAnimatedLink.mBuyOnlineText.arrowMC.gotoAndStop("on");
  214.          temp.text = bodyLinkMC.mAnimatedLink.mBuyOnlineText.arrowMC;
  215.       }
  216.       else
  217.       {
  218.          bodyLinkMC.arrowMC.gotoAndStop("on");
  219.          bodyLinkMC.contentFF.textColor = SECTION_COLOR;
  220.       }
  221.    }
  222. }
  223. function txtOut(mc)
  224. {
  225.    var _loc1_ = mc;
  226.    Tardis.sideMenu.doOut(_loc1_.link);
  227.    if(_loc1_.imageRoll)
  228.    {
  229.       mc_images.doOut(_loc1_.num);
  230.    }
  231.    if(_loc1_ == bodyLinkMC)
  232.    {
  233.       if(animatedLink)
  234.       {
  235.          bodyLinkMC.mAnimatedLink.mBuyOnlineText.txtLabel.textColor = SECTION_COLOR50;
  236.          bodyLinkMC.mAnimatedLink.mBuyOnlineText2.contentFF.textColor = SECTION_COLOR50;
  237.          bodyLinkMC.mAnimatedLink.mBuyOnlineText.arrowMC.gotoAndStop("off");
  238.       }
  239.       else
  240.       {
  241.          bodyLinkMC.arrowMC.gotoAndStop("off");
  242.          bodyLinkMC.contentFF.textColor = SECTION_COLOR50;
  243.       }
  244.    }
  245. }
  246. function txtUp(mc)
  247. {
  248.    var _loc1_ = mc;
  249.    if(_loc1_.printImage != null)
  250.    {
  251.       printImage(_loc1_.printImage);
  252.    }
  253.    if(_loc1_.link == "print")
  254.    {
  255.       printImage(_loc1_.link);
  256.    }
  257.    else
  258.    {
  259.       Tardis.sideMenu.doUp(_loc1_.link);
  260.    }
  261. }
  262. function doOver(num)
  263. {
  264.    if(bodyLinkMC.link == num)
  265.    {
  266.       if(animatedLink)
  267.       {
  268.          bodyLinkMC.mAnimatedLink.mBuyOnlineText.txtLabel.textColor = SECTION_COLOR;
  269.          bodyLinkMC.mAnimatedLink.mBuyOnlineText2.contentFF.textColor = SECTION_COLOR;
  270.          bodyLinkMC.mAnimatedLink.mBuyOnlineText.arrowMC.gotoAndStop("on");
  271.       }
  272.       else
  273.       {
  274.          bodyLinkMC.contentFF.textColor = SECTION_COLOR;
  275.          bodyLinkMC.arrowMC.gotoAndStop("on");
  276.       }
  277.    }
  278.    else
  279.    {
  280.       var mc = eval("mc_t_" + num);
  281.       mc.titleFF.textColor = SECTION_COLOR;
  282.    }
  283. }
  284. function doOut(num)
  285. {
  286.    if(bodyLinkMC.link == num)
  287.    {
  288.       if(animatedLink)
  289.       {
  290.          bodyLinkMC.mAnimatedLink.mBuyOnlineText.txtLabel.textColor = SECTION_COLOR50;
  291.          bodyLinkMC.mAnimatedLink.mBuyOnlineText2.contentFF.textColor = SECTION_COLOR50;
  292.          bodyLinkMC.mAnimatedLink.mBuyOnlineText.arrowMC.gotoAndStop("off");
  293.       }
  294.       else
  295.       {
  296.          bodyLinkMC.contentFF.textColor = SECTION_COLOR50;
  297.          bodyLinkMC.arrowMC.gotoAndStop("off");
  298.       }
  299.    }
  300.    else
  301.    {
  302.       var mc = eval("mc_t_" + num);
  303.       mc.titleFF.textColor = DEFAULT_COLOR;
  304.    }
  305. }
  306. function printImage(strFile)
  307. {
  308.    var _loc2_ = strFile;
  309.    if(System.capabilities.os.toUpperCase().indexOf("MAC OS 9") != -1)
  310.    {
  311.       lingo("Flsh_alert \"Sorry, this functionality is not available on Mac OS 9\"");
  312.    }
  313.    else
  314.    {
  315.       var _loc1_ = Tardis.ASSETS_FOLDER + "images/" + Tardis.ActiveSection.id + "/" + IMAGE_PATH;
  316.       imgPrint = false;
  317.       nmWaitID = setInterval(this,"checkImage",500);
  318.       mc_image.printImageMC.loadMovie(_loc1_ + _loc2_);
  319.    }
  320. }
  321. function checkImage()
  322. {
  323.    if(mc_image.printImageMC._height > 0 && !imgPrint)
  324.    {
  325.       imgPrint = true;
  326.       clearInterval(nmWaitID);
  327.       getURL("printasbitmap:",mc_image.printImageMC);
  328.    }
  329. }
  330. _root.core = this;
  331. Links = {};
  332. Tardis.sideMenu.EB.addListener(this);
  333. stop();
  334. _visible = false;
  335. TEXT_POS = 10;
  336. CONTENT_POS = 0;
  337. positioned = false;
  338. onReady();
  339. this.onUnload = function()
  340. {
  341.    removeLinkListener();
  342.    clearInterval(intervalID);
  343.    clearInterval(nmWaitID);
  344.    this.onUnload = null;
  345. };
  346. bodyLinkMC.btn.onRelease = function()
  347. {
  348.    this._parent._parent.txtUp(this._parent);
  349. };
  350. bodyLinkMC.btn.onRollOver = function()
  351. {
  352.    this._parent._parent.txtOver(this._parent);
  353. };
  354. bodyLinkMC.btn.onRollOut = function()
  355. {
  356.    this._parent._parent.txtOut(this._parent);
  357. };
  358.